package cn.doitedu.groovy;

import groovy.lang.GroovyClassLoader;

public class EntryPoint {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

        String code = "package cn.doitedu.groovy\n" +
                "\n" +
                "class ACalculator implements Calculator{\n" +
                "    @Override\n" +
                "    void init() {\n" +
                "        System.out.println(\"init 了\")\n" +
                "    }\n" +
                "\n" +
                "    @Override\n" +
                "    void calc() {\n" +
                "        System.out.println(\"calc 了\")\n" +
                "    }\n" +
                "}";

        GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
        Class aClass = groovyClassLoader.parseClass(code);



        Calculator calculator = (Calculator) aClass.newInstance();
        calculator.init();
        calculator.calc();




    }
}
